/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jili.ubert.dao.db;

import java.io.Serializable;
import com.baidu.bjf.remoting.protobuf.Codec;
import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
import com.jili.ubert.code.CodeTool;
import java.io.IOException;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dragon
 */
@Entity
@Table(name = "obj_newstock")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ObjNewStock.findAll", query = "SELECT o FROM ObjNewStock o"),
    @NamedQuery(name = "ObjNewStock.findById", query = "SELECT o FROM ObjNewStock o WHERE o.id = :id"),
    @NamedQuery(name = "ObjNewStock.findByObj", query = "SELECT o FROM ObjNewStock o WHERE o.obj = :obj"),
    @NamedQuery(name = "ObjNewStock.findByPrimaryObj", query = "SELECT o FROM ObjNewStock o WHERE o.primaryObj = :primaryObj"),
    @NamedQuery(name = "ObjNewStock.findByName", query = "SELECT o FROM ObjNewStock o WHERE o.name = :name"),
    @NamedQuery(name = "ObjNewStock.findByRegionID", query = "SELECT o FROM ObjNewStock o WHERE o.regionID = :regionID"),
    @NamedQuery(name = "ObjNewStock.findByMarketCode", query = "SELECT o FROM ObjNewStock o WHERE o.marketCode = :marketCode"),
    @NamedQuery(name = "ObjNewStock.findByClassCode", query = "SELECT o FROM ObjNewStock o WHERE o.classCode = :classCode"),
    @NamedQuery(name = "ObjNewStock.findByTradeUnit", query = "SELECT o FROM ObjNewStock o WHERE o.tradeUnit = :tradeUnit"),
    @NamedQuery(name = "ObjNewStock.findByMaxQty", query = "SELECT o FROM ObjNewStock o WHERE o.maxQty = :maxQty"),
    @NamedQuery(name = "ObjNewStock.findByPrimaryTradeDate", query = "SELECT o FROM ObjNewStock o WHERE o.primaryTradeDate = :primaryTradeDate"),
    @NamedQuery(name = "ObjNewStock.findByTradeDate", query = "SELECT o FROM ObjNewStock o WHERE o.tradeDate = :tradeDate"),
    @NamedQuery(name = "ObjNewStock.findByOwnUserID", query = "SELECT o FROM ObjNewStock o WHERE o.ownUserID = :ownUserID"),
    @NamedQuery(name = "ObjNewStock.findByAlterUserID", query = "SELECT o FROM ObjNewStock o WHERE o.alterUserID = :alterUserID"),
    @NamedQuery(name = "ObjNewStock.findByCreateTime", query = "SELECT o FROM ObjNewStock o WHERE o.createTime = :createTime"),
    @NamedQuery(name = "ObjNewStock.findByTimeStamp", query = "SELECT o FROM ObjNewStock o WHERE o.timeStamp = :timeStamp")})
public class ObjNewStock implements Serializable {
	public static byte[] EnCode(ObjNewStock msg) throws IOException {
		Codec<ObjNewStock> Lcode = ProtobufProxy.create(ObjNewStock.class);
		return Lcode.encode(msg);
	}
	public static ObjNewStock DeCode(byte[] data) throws IOException {
	Codec<ObjNewStock> Lcode = ProtobufProxy.create(ObjNewStock.class);
		return Lcode.decode(data);
	}

    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    @Protobuf
	private Integer id;
    @Basic(optional = false)
    @Column(name = "Obj")
    @Protobuf
	private String obj;
    @Basic(optional = false)
    @Column(name = "PrimaryObj")
    @Protobuf
	private String primaryObj;
    @Basic(optional = false)
    @Column(name = "Name")
    private String name;
	@Protobuf
	private byte[] nameBit;
    @Column(name = "RegionID")
    @Protobuf
	private String regionID;
    @Basic(optional = false)
    @Column(name = "MarketCode")
    @Protobuf
	private String marketCode;
    @Basic(optional = false)
    @Column(name = "ClassCode")
    @Protobuf
	private String classCode;
    @Basic(optional = false)
    @Column(name = "TradeUnit")
    @Protobuf
	private int tradeUnit;
    @Basic(optional = false)
    @Column(name = "MaxQty")
    @Protobuf
	private int maxQty;
    @Basic(optional = false)
    @Column(name = "PrimaryTradeDate")
    @Temporal(TemporalType.DATE)
    private Date primaryTradeDate;
	@Protobuf
	private long primaryTradeDateL;
    @Basic(optional = false)
    @Column(name = "TradeDate")
    @Temporal(TemporalType.DATE)
    private Date tradeDate;
	@Protobuf
	private long tradeDateL;
    @Column(name = "OwnUserID")
    @Protobuf
	private String ownUserID;
    @Column(name = "AlterUserID")
    @Protobuf
	private String alterUserID;
    @Column(name = "CreateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
	//@Protobuf
//tprivate long createTimeL;
    @Column(name = "TimeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
	//@Protobuf
	//private long timeStampL;

    public ObjNewStock() {
    }

    public ObjNewStock(Integer id) {
        this.id = id;
    }

    public ObjNewStock(Integer id, String obj, String primaryObj, String name, String marketCode, String classCode, int tradeUnit, int maxQty, Date primaryTradeDate, Date tradeDate) {
        this.id = id;
        this.obj = obj;
        this.primaryObj = primaryObj;
        this.name = name;
		this.nameBit = CodeTool.StringToBit(name);
        this.marketCode = marketCode;
        this.classCode = classCode;
        this.tradeUnit = tradeUnit;
        this.maxQty = maxQty;
        this.primaryTradeDate = primaryTradeDate;
		this.primaryTradeDateL = CodeTool.DateToLong(primaryTradeDate);
        this.tradeDate = tradeDate;
		this.tradeDateL = CodeTool.DateToLong(tradeDate);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getObj() {
        return obj;
    }

    public void setObj(String obj) {
        this.obj = obj;
    }

    public String getPrimaryObj() {
        return primaryObj;
    }

    public void setPrimaryObj(String primaryObj) {
        this.primaryObj = primaryObj;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        this.setNameBit(CodeTool.StringToBit(name));
    }

    public String getRegionID() {
        return regionID;
    }

    public void setRegionID(String regionID) {
        this.regionID = regionID;
    }

    public String getMarketCode() {
        return marketCode;
    }

    public void setMarketCode(String marketCode) {
        this.marketCode = marketCode;
    }

    public String getClassCode() {
        return classCode;
    }

    public void setClassCode(String classCode) {
        this.classCode = classCode;
    }

    public int getTradeUnit() {
        return tradeUnit;
    }

    public void setTradeUnit(int tradeUnit) {
        this.tradeUnit = tradeUnit;
    }

    public int getMaxQty() {
        return maxQty;
    }

    public void setMaxQty(int maxQty) {
        this.maxQty = maxQty;
    }

    public Date getPrimaryTradeDate() {
        return primaryTradeDate;
    }

    public void setPrimaryTradeDate(Date primaryTradeDate) {
        this.primaryTradeDate = primaryTradeDate;
		this.setPrimaryTradeDateL(CodeTool.DateToLong(primaryTradeDate));
    }

    public Date getTradeDate() {
        return tradeDate;
    }

    public void setTradeDate(Date tradeDate) {
        this.tradeDate = tradeDate;
		this.setTradeDateL(CodeTool.DateToLong(tradeDate));
    }

    public String getOwnUserID() {
        return ownUserID;
    }

    public void setOwnUserID(String ownUserID) {
        this.ownUserID = ownUserID;
    }

    public String getAlterUserID() {
        return alterUserID;
    }

    public void setAlterUserID(String alterUserID) {
        this.alterUserID = alterUserID;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
		//this.createTimeL = CodeTool.DateToLong(createTime);
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
		//this.timeStampL = CodeTool.DateToLong(timeStamp);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ObjNewStock)) {
            return false;
        }
        ObjNewStock other = (ObjNewStock) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jili.ubert.dao.db.ObjNewStock[ id=" + id + " ]";
    }

    public byte[] getNameBit() {
        return nameBit;
    }

    public void setNameBit(byte[] nameBit) {
        this.nameBit = nameBit;
		this.name = CodeTool.BitToString(nameBit);
    }

    public long getPrimaryTradeDateL() {
        return primaryTradeDateL;
    }

    public void setPrimaryTradeDateL(long primaryTradeDateL) {
        this.primaryTradeDateL = primaryTradeDateL;
		this.primaryTradeDate = CodeTool.LongToDate(primaryTradeDateL);
    }

    public long getTradeDateL() {
        return tradeDateL;
    }

    public void setTradeDateL(long tradeDateL) {
        this.tradeDateL = tradeDateL;
		this.tradeDate = CodeTool.LongToDate(tradeDateL);
    }
    
}
